/**
 * 初始化轮播表详情对话框
 */
var LunboPicInfoDlg = {
    lunboPicInfoData : {}
};

/**
 * 清除数据
 */
LunboPicInfoDlg.clearData = function() {
    this.lunboPicInfoData = {};
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
LunboPicInfoDlg.set = function(key, val) {
    this.lunboPicInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
    return this;
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
LunboPicInfoDlg.get = function(key) {
    return $("#" + key).val();
}

/**
 * 关闭此对话框
 */
LunboPicInfoDlg.close = function() {
    parent.layer.close(window.parent.LunboPic.layerIndex);
}

/**
 * 收集数据
 */
LunboPicInfoDlg.collectData = function() {
    this.set('id').set('infoId').set('picture1').set('picture2').set('picture3').set('picture4').set('picture5');
}
/**
 * 提交添加
 */
LunboPicInfoDlg.addSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/lunboPic/add", function(data){
        Feng.success("添加成功!");
        window.parent.LunboPic.table.refresh();
        LunboPicInfoDlg.close();
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.lunboPicInfoData);
    ajax.start();
}

/**
 * 提交修改
 */
LunboPicInfoDlg.editSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/lunboPic/update", function(data){
        Feng.success("修改成功!");
        window.parent.LunboPic.table.refresh();
        LunboPicInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.lunboPicInfoData);
    ajax.start();
}

$(function() {
    var picture1Up = new $WebUpload("picture1",Feng.ctxPath + '/lunboPic/upload');
    var picture2Up = new $WebUpload("picture2",Feng.ctxPath + '/lunboPic/upload');
    var picture3Up = new $WebUpload("picture3",Feng.ctxPath + '/lunboPic/upload');
    var picture4Up = new $WebUpload("picture4",Feng.ctxPath + '/lunboPic/upload');
    var picture5Up = new $WebUpload("picture5",Feng.ctxPath + '/lunboPic/upload');
    picture1Up.init();
    picture2Up.init();
    picture3Up.init();
    picture4Up.init();
    picture5Up.init();
});
